package com.scnu.hachimi.controller;

import com.scnu.hachimi.manager.ObjectManager;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

public class KeyboardListener extends KeyAdapter{
    private ObjectManager objectManager;

    public KeyboardListener(ObjectManager om) {
        objectManager = om;
    }


    public void keyPressed(KeyEvent e)
    {
        objectManager.kb.put(e.getKeyCode(), true);
        objectManager.keyTimeSet.put(e.getKeyCode(), System.currentTimeMillis());
//        System.out.println("按下" + e.getKeyCode());
    }

    public void keyReleased(KeyEvent e)
    {
        objectManager.kb.put(e.getKeyCode(), false);
//        System.out.println("松开" + e.getKeyCode());
    }
}
